package com.mairuide.robot.participles;

import com.mairuide._frame.base.BaseRepository;
import com.mairuide._frame.base.BaseServiceProxy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Service
@Transactional
public class MParticiplesService extends BaseServiceProxy<MParticiples> {
	
	@Resource
	private MParticiplesRepository mparticiplesRepository;
	
	@Override
	protected BaseRepository<MParticiples> getBaseRepository() {
		return mparticiplesRepository;
	}
	
	/**
	 * 根据时间查询未加入分词库分词信息
	 * @param time
	 * @return
	 */
	public List<String> getParticiples4CreateTime(Date time){
		List<MParticiples> list = mparticiplesRepository.getParticiples4CreateTime(time);
		List<String> participlesList = list.stream().map(p -> p.getParticiples()).collect(Collectors.toList());
		return participlesList;
	}
	
	
	/**
	 * 问题id查询分词
	 * @param qpId
	 * @return
	 */
	public List<MParticiples> findByQpId(Integer qpId){
		return mparticiplesRepository.findByQpId(qpId);
	}
	
	/**
	 * 根据父表id删除分词
	 * @param qpId
	 * @return 
	 */
	public void deleteByQpId(Integer qpId) {
		mparticiplesRepository.deleteByQpId(qpId);
	}
}
